﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<TestWeb.Models.ViewModel>" %>

<% using (Html.BeginForm("UpdateNguoiDung", "Admin", FormMethod.Post, new { id = "MySubmitForm" }))
   { %>
    <!-- start table-content  -->
    <div id="table-content">
        <!--  start message-blue -->
	    <div id="message-blue">
		    <table border="0" width="100%" cellpadding="0" cellspacing="0">
			    <tr>
				    <td class="blue-left">Information message</td>
			    </tr>
		    </table>
	    </div>
        <!--  end message-blue -->
        <script type="text/javascript">
                <% if (ViewData["MsgTxt"] != null && ViewData["MsgTxt"] != string.Empty)
                { %>
		            $(".blue-left").text('<%= ViewData["MsgTxt"] %>');
                    $("#message-blue").fadeIn('fast').delay(<%= WebConfiguration.Instance.InfoTime %>).fadeOut('slow'); 
	            <% } %>
        </script>

	    <!-- start product-table -->
	    <table border="0" width="100%" cellpadding="0" cellspacing="0" id="product-table">
		    <tr>
                <th class="table-header-repeat line-left">
				    <a href="#">UserID</a>
			    </th>
			    <th class="table-header-repeat line-left">
				    <a href="#">UserName</a>
			    </th>
                <th class="table-header-repeat line-left">
				    <a href="#">Role</a>
			    </th>
                <th class="table-header-repeat line-left" style="text-align: center;">
				    <a href="#">Enable?</a>
			    </th>
			    <th class="table-header-options line-left">
				    <a href="#">Option</a>
			    </th>
		    </tr>
	    <% for (int i = 0; i < Model.NguoiDungs.Count; i++)
        {
            var item = Model.NguoiDungs[i]; %>
		    <% if (i % 2 == 0)
            { %>
		    <tr id="row-<%= item.NguoiDung.ID %>" class="row-table odd-row">
		 <% }
            else
            { %>
		    <tr id="row-<%= item.NguoiDung.ID %>" class="row-table even-row">
		 <% } %>
            <% if (item.NguoiDung.ID == (Guid)ViewData["EditItem"])
               { %>
                <td>
				    <%= item.NguoiDung.ID %>
			    </td>
			    <td>
				    <%= item.UserName %>
			    </td>
                <td>
				    <%= item.Role %>
			    </td>
                <td style="text-align: center;">
                    <%= Html.CheckBox("IsEnable", item.IsEnable) %>
			    </td>
			    <td class="options-width">
                    <input type="hidden" name="ID" value="<%= item.NguoiDung.ID %>" />
                    <input type="hidden" name="Role" value="SuperAdmin" />
                    <input type="hidden" name="CurrentPage" value="<%= (int)ViewData["CurrentPage"] %>" />
				    <%= Ajax.ActionLink(" ", "DetailOfNguoiDung", new { ID = item.NguoiDung.ID, CurrentPage = (int)ViewData["CurrentPage"] }, new AjaxOptions { OnComplete = "DetailOfNguoiDung_OnComplete" }, new { @class = "icon-5 info-tooltip", @title = "Select" })%>
                    <a href="#"  title="Update" class="icon-6 info-tooltip" onclick="submitFormNguoiDung();"></a>
				    <%= Ajax.ActionLink(" ", "CancelEditingNguoiDung", "Admin", new { Role = "SuperAdmin", CurrentPage = (int)ViewData["CurrentPage"] }, new AjaxOptions { UpdateTargetId = "PartialDiv" }, new { @class = "icon-7 info-tooltip", @title = "Cancel" })%>
                    <%= Ajax.ActionLink(" ", "DeleteNguoiDung", "Admin", new { id = item.NguoiDung.ID }, new AjaxOptions { Confirm = "Are you sure you want to Delete it? This action cannot be undone.", HttpMethod = "Delete", OnComplete = "jsonDelete_OnComplete" }, new { @class = "icon-2 info-tooltip", @title = "Delete" })%>
			    </td>
            <% }
               else
               { %>
                <td>
				    <%= item.NguoiDung.ID%>
			    </td>
			    <td>
				    <%= item.UserName%>
			    </td>
                <td>
				    <%= item.Role%>
			    </td>
                <td style="text-align: center;">
                    <%= Html.CheckBox("IsEnable", item.IsEnable, new { disabled = "disabled" })%>
			    </td>
			    <td class="options-width">
				    <%= Ajax.ActionLink(" ", "DetailOfNguoiDung", new { ID = item.NguoiDung.ID, CurrentPage = (int)ViewData["CurrentPage"] }, new AjaxOptions { OnComplete = "DetailOfNguoiDung_OnComplete" }, new { @class = "icon-5 info-tooltip", @title = "Select" })%>
                    <%= Ajax.ActionLink(" ", "EditNguoiDung", new { ID = item.NguoiDung.ID, Role = "SuperAdmin", CurrentPage = (int)ViewData["CurrentPage"] }, new AjaxOptions { UpdateTargetId = "PartialDiv" }, new { @class = "icon-1 info-tooltip", @title = "Edit" })%>
                    <%= Ajax.ActionLink(" ", "DeleteNguoiDung", "Admin", new { id = item.NguoiDung.ID }, new AjaxOptions { Confirm = "Are you sure you want to Delete it? This action cannot be undone.", HttpMethod = "Delete", OnComplete = "jsonDelete_OnComplete" }, new { @class = "icon-2 info-tooltip", @title = "Delete" })%>
			    </td>
            <% } %>     
		    </tr>
	    <% } %>
	    </table>
	    <!-- end product-table -->
	    <!-- start paging -->
	    <div class="pagination">
	    <% 
        var nextPage = (int)ViewData["CurrentPage"] + 1;
        var totalPage = (int)ViewData["TotalPage"];
        if (nextPage <= totalPage)
        { %>
	    <%= Html.ActionLink(" ", "SelectNguoiDung", new { Page = nextPage })%>
		    <% } %>
	    </div>
	    <!-- end paging -->
    </div>
    <!-- end content-table  -->
<% }  %>